import React, { FC } from 'react';
import { useDispatch } from 'react-redux';
import { useNavigate } from 'react-router-dom';
//
import useGetUserInfo from '@/hooks/useGetUserInfo';
import { logoutReducer } from '@/store/userReducer';
//
import { message } from 'antd';
import { UserOutlined } from '@ant-design/icons';

const UserInfo:FC=()=>{

    const nav=useNavigate()
    const dispatch=useDispatch()

    const { username, nickname }= useGetUserInfo()

    function logout(){
        dispatch(logoutReducer())
        removeToken()
        message.success('退出成功')
        nav('/login')
    }

    const UserInfo=(
        <>
        <span>
            <UserOutlined/>
            {nickname || username}
        </span>
        </>
    )
}

export default UserInfo;